import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/user/Login.vue'),
      meta: { noLayout: true }
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('../views/user/Register.vue'),
      meta: { noLayout: true }
    },
    {
      path: '/merchant/login',
      name: 'merchantLogin',
      component: () => import('../views/merchant/Login.vue'),
      meta: { noLayout: true }
    },
    {
      path: '/user',
      name: 'user',
      component: () => import('../layouts/UserLayout.vue'),
      children: [
        {
          path: '',
          redirect: '/user/dish'
        },
        {
          path: 'home',
          name: 'userHome',
          component: () => import('../views/user/Home.vue')
        },
        {
          path: 'dish',
          name: 'userDish',
          component: () => import('../views/user/Dish.vue')
        },
        {
          path: 'order',
          name: 'userOrder',
          component: () => import('../views/user/Order.vue')
        },
        {
          path: 'points',
          name: 'userPoints',
          component: () => import('../views/user/Points.vue')
        },
        {
          path: 'feedback',
          name: 'userFeedback',
          component: () => import('../views/user/Feedback.vue')
        }
      ]
    },
    {
      path: '/merchant',
      name: 'merchant',
      component: () => import('../layouts/MerchantLayout.vue'),
      children: [
        {
          path: '',
          redirect: '/merchant/order'
        },
        {
          path: 'dish',
          name: 'merchantDish',
          component: () => import('../views/merchant/Dish.vue')
        },
        {
          path: 'order',
          name: 'merchantOrder',
          component: () => import('../views/merchant/Order.vue')
        },
        {
          path: 'inventory',
          name: 'merchantInventory',
          component: () => import('../views/merchant/Inventory.vue')
        },
        {
          path: 'feedback',
          name: 'merchantFeedback',
          component: () => import('../views/merchant/Feedback.vue')
        },
        {
          path: 'users',
          name: 'merchantUsers',
          component: () => import('../views/merchant/UserManagement.vue')
        },
        {
          path: 'statistics',
          name: 'merchantStatistics',
          component: () => import('../views/merchant/Statistics.vue')
        }
      ]
    }
  ]
})

export default router
